package com.yvon.maple.service.seckill.controller;

import com.yvon.boot.common.result.ResponseData;
import com.yvon.boot.mybatis.page.ListData;
import com.yvon.boot.mybatis.search.PageQuery;
import com.yvon.maple.cloud.web.data.AbstractController;
import com.yvon.maple.service.seckill.dto.SeckillOrderDTO;
import com.yvon.maple.service.seckill.entity.SeckillOrder;
import com.yvon.maple.service.seckill.service.SeckillOrderService;
import com.yvon.maple.service.seckill.vo.SeckillOrderVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * 秒杀订单controller
 *
 * @author Yvon
 * @date 2024-10-24
 */
@RestController
@RequestMapping(value = "/orders")
@Api(value = "订单管理", tags = "秒杀服务 - 订单管理API")
public class SeckillOrderController extends AbstractController<SeckillOrder, SeckillOrderDTO, SeckillOrderVO, SeckillOrderService> {

//    @PostMapping
//    @ApiOperation(value = "保存订单", notes = "保存订单API")
//    public ResponseData<SeckillOrderDTO> saveOrder(@RequestBody SeckillOrderVO vo) {
//        getService().saveOrder(vo);
//        return success(this.entityToDto());
//    }

    @GetMapping({"page"})
    @ApiOperation(value = "分页查询", notes = "分页查询API")
    public ResponseData<ListData<SeckillOrderDTO>> page(PageQuery pageQuery) {
        ListData listData = getService().page(pageQuery);
        listData.setList(this.entityToDto(listData.getList()));
        return success(listData);
    }
}

